Imports System.Math
Imports System.Drawing.Drawing2D


Module modCommon

    Public Const c_Demo As Boolean = True
    Public Const c_GameSystemVersion As String = "0.2.3"
    Public Const c_IconHalfWidth = 16
    Public Const c_IconHalfHeight = 16

    Public Function XYDistance(ByVal X1, ByVal X2, ByVal Y1, ByVal Y2) As Integer
        'returns the distance between two 2d coordinates
        XYDistance = Int(Abs(Math.Sqrt(((X1 - X2) * (X1 - X2)) + ((Y1 - Y2) * (Y1 - Y2)))))

    End Function


    Public Sub DrawZOC(ByVal gr As Graphics, ByVal pnt As Point, ByVal radius As Int16, Optional ByVal enemy As Boolean = False)

        If radius = 0 Then Exit Sub

        pnt.X -= radius / 2
        pnt.Y -= radius / 2

        If enemy Then
            gr.DrawEllipse(New Pen(Color.FromArgb(255, 255, 75, 75)), pnt.X, pnt.Y, radius, radius)
            gr.FillEllipse(New SolidBrush(Color.FromArgb(100, 255, 75, 75)), pnt.X, pnt.Y, radius, radius)

        Else
            gr.DrawEllipse(New Pen(Color.FromArgb(255, 75, 255, 75)), pnt.X, pnt.Y, radius, radius)
            gr.FillEllipse(New SolidBrush(Color.FromArgb(100, 75, 255, 75)), pnt.X, pnt.Y, radius, radius)
        End If

    End Sub

    Public Sub DrawBorderedCircle(ByVal gr As Graphics, ByVal pnt As Point, ByVal radius As Int16, ByVal outterColor As Color, ByVal innerColor As Color)
        Dim outter As New Pen(outterColor)
        Dim inner As New Pen(innerColor)

        pnt.X -= radius / 2
        pnt.Y -= radius / 2

        gr.DrawEllipse(outter, pnt.X, pnt.Y, radius, radius)
        gr.DrawEllipse(inner, pnt.X + 1, pnt.Y + 1, radius - 2, radius - 2)
        gr.DrawEllipse(outter, pnt.X + 2, pnt.Y + 2, radius - 4, radius - 4)


    End Sub


End Module
